package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.OrderHistory;
import com.pgybook.db.entity.domain.OrderHistoryEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface OrderHistoryMapper {
    int countByExample(OrderHistoryEx example);

    int deleteByExample(OrderHistoryEx example);

    @Delete({
            "delete from orderhistory",
            "where ORDERHISID = #{orderhisid,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long orderhisid);

    @Insert({
            "insert into orderhistory (ORDERID, MODTYPE, ",
            "CRTTIME, CRTSTAFF, ",
            "ORGDATA, DESDATA)",
            "values (#{orderid,jdbcType=BIGINT}, #{modtype,jdbcType=INTEGER}, ",
            "#{crttime,jdbcType=TIMESTAMP}, #{crtstaff,jdbcType=INTEGER}, ",
            "#{orgdata,jdbcType=VARCHAR}, #{desdata,jdbcType=VARCHAR})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "orderhisid", before = false, resultType = Long.class)
    int insert(OrderHistory record);

    int insertSelective(OrderHistory record);

    List<OrderHistory> selectByExample(OrderHistoryEx example);

    @Select({
            "select",
            "ORDERHISID, ORDERID, MODTYPE, CRTTIME, CRTSTAFF, ORGDATA, DESDATA",
            "from orderhistory",
            "where ORDERHISID = #{orderhisid,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    OrderHistory selectByPrimaryKey(Long orderhisid);

    int updateByExampleSelective(@Param("record") OrderHistory record, @Param("example") OrderHistoryEx example);

    int updateByExample(@Param("record") OrderHistory record, @Param("example") OrderHistoryEx example);

    int updateByPrimaryKeySelective(OrderHistory record);

    @Update({
            "update orderhistory",
            "set ORDERID = #{orderid,jdbcType=BIGINT},",
            "MODTYPE = #{modtype,jdbcType=INTEGER},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP},",
            "CRTSTAFF = #{crtstaff,jdbcType=INTEGER},",
            "ORGDATA = #{orgdata,jdbcType=VARCHAR},",
            "DESDATA = #{desdata,jdbcType=VARCHAR}",
            "where ORDERHISID = #{orderhisid,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(OrderHistory record);
}
